<?php

namespace App\ServicesNew;

use App\Entities\CouponCodeEntity;
use App\Entities\OrderEntity;
use App\Entities\UserCouponEntity;
use App\VO\UserCoupon\MetaInfo\UserCouponSearchInfo;

interface CouponService
{
    /**
     * @param int $couponId
     * @return CouponCodeEntity|null
     */
    public function findCouponEntityById(int $couponId);

    /**
     * @param int $couponId
     * @param int $userId
     * @return CouponCodeEntity|null
     */
    public function findCouponEntityByIdAndUserId(int $couponId, int $userId);

    /**
     * @param int $couponId
     * @param int $userId
     * @return UserCouponEntity|null
     */
    public function findUserCouponEntityByCouponIdAndUserId(int $couponId, int $userId);


    /**
     * @param UserCouponSearchInfo $searchInfo
     * @return CouponCodeEntity[]
     */
    public function getCouponEntities(UserCouponSearchInfo $searchInfo);

    /**
     * @param UserCouponSearchInfo $searchInfo
     * @return int
     */
    public function count(UserCouponSearchInfo $searchInfo);

    /**
     * 使用优惠券
     * @param OrderEntity $orderEntity
     * @param int $couponId
     * @return mixed
     */
    public function orderUseCouponByCouponId(OrderEntity $orderEntity, int $couponId);

    /**
     * 使用优惠券
     * @param OrderEntity $orderEntity
     * @param CouponCodeEntity $couponCodeEntity
     * @return mixed
     */
    public function orderUseCouponByCouponEntity(OrderEntity $orderEntity, CouponCodeEntity $couponCodeEntity);

    /**
     * 获取用户可以使用的优惠券
     * @param int $userId
     * @return CouponCodeEntity[]
     */
    public function getUseAbleCouponCodeListByUserId(int $userId);

    /**
     * 订单回退时，回滚优惠券操作
     * @param OrderEntity $orderEntity
     * @return void
     */
    public function orderRollback(OrderEntity $orderEntity);
}
